﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Globalization;
using System.Threading;
using System.Text;

namespace Code4WP7SDK
{
    public class MonthHelper
    {
        public static string GetChinaMonthName(int _month)
        {
            string monthName = "";
            switch (_month)
            {
                case 1:
                    monthName = "一月";
                    break;
                case 2:
                    monthName = "二月";
                    break;
                case 3:
                    monthName = "三月";
                    break;
                case 4:
                    monthName = "四月";
                    break;
                case 5:
                    monthName = "五月";
                    break;
                case 6:
                    monthName = "六月";
                    break;
                case 7:
                    monthName = "七月";
                    break;
                case 8:
                    monthName = "八月";
                    break;
                case 9:
                    monthName = "九月";
                    break;
                case 10:
                    monthName = "十月";
                    break;
                case 11:
                    monthName = "十一月";
                    break;
                case 12:
                    monthName = "十二月";
                    break;
            }
            return monthName;
        }

        public static string GetEnglistMonthName(int _month)
        {
            string monthName = "";
            switch (_month)
            {
                case 1:
                    monthName = "Jan";
                    break;
                case 2:
                    monthName = "Feb";
                    break;
                case 3:
                    monthName = "Mar";
                    break;
                case 4:
                    monthName = "Apr";
                    break;
                case 5:
                    monthName = "May";
                    break;
                case 6:
                    monthName = "Jun";
                    break;
                case 7:
                    monthName = "Jul";
                    break;
                case 8:
                    monthName = "Arg";
                    break;
                case 9:
                    monthName = "Sep";
                    break;
                case 10:
                    monthName = "Oct";
                    break;
                case 11:
                    monthName = "Dec";
                    break;
                case 12:
                    monthName = "Nov";
                    break;
            }
            return monthName;
        }

        public static int GetIntMonthNumber(string chinaMonth)
        {
            int month = 1;
            switch (chinaMonth)
            {
                case "Jan":
                    month = 1;
                    break;
                case "Feb":
                    month = 2;
                    break;
                case "Mar":
                    month = 3;
                    break;
                case "Apr":
                    month = 4;
                    break;
                case "May":
                    month = 5;
                    break;
                case "Jun":
                    month = 6;
                    break;
                case "Jul":
                    month = 7;
                    break;
                case "Arg":
                    month = 8;
                    break;
                case "Sep":
                    month = 9;
                    break;
                case "Oct":
                    month = 10;
                    break;
                case "Nov":
                    month = 11;
                    break;
                case "Dec":
                    month = 12;
                    break;
                case "一月":
                    month = 1;
                    break;
                case "二月":
                    month = 2;
                    break;
                case "三月":
                    month = 3;
                    break;
                case "四月":
                    month = 4;
                    break;
                case "五月":
                    month = 5;
                    break;
                case "六月":
                    month = 6;
                    break;
                case "七月":
                    month = 7;
                    break;
                case "八月":
                    month = 8;
                    break;
                case "九月":
                    month = 9;
                    break;
                case "十月":
                    month = 10;
                    break;
                case "十一月":
                    month = 11;
                    break;
                case "十二月":
                    month = 12;
                    break;
            }
            return month;
        }
        /// <summary>
        /// 转换标准英文日期格式
        /// </summary>
        /// <param name="dateStr"></param>
        /// <returns></returns>
        public static string ConvertEnglistDate(string dateStr)
        {
            //CultureInfo cultureInfo = new CultureInfo("en_US");
            CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
            string format = "ddd MMM d HH:mm:ss zz00 yyyy";
            //string stringValue = DateTime.Now.ToString(format, cultureInfo); // 得到日期字符串 DateTime datetime = DateTime.ParseExact("Wed Aug 25 16:28:03 +0800 2010", format, cultureInfo); // 将字符串转换成日期
            DateTime datetime = DateTime.ParseExact(dateStr, format, CultureInfo.InvariantCulture);
            return datetime.ToString("yyyy-MM-dd HH:mm:ss");
        }
        /// <summary>
        /// 将毫秒转换成时分秒
        /// </summary>
        /// <param name="time"></param>
        /// <returns></returns>
        public static string ConvertTime(string time)
        {
            StringBuilder sb = new StringBuilder();
            TimeSpan ts = new TimeSpan(0, 0, 0, 0, int.Parse(time));
            return sb.AppendFormat("{0}:{1}:{2}",ts.Hours.ToString(),ts.Minutes.ToString(),ts.Seconds.ToString()).ToString();
        }
    }


}
